main()
{
	long a,b,t;
	for(gets(&a);~scanf("%ld%ld",&a,&b);printf("%ld\n",a))
		while(b)
		{
			t=a%b;
			a=b;
			b=t;
		}
}
